/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package draftMate.player;

import draftMate.DraftMate;
import javax.swing.table.AbstractTableModel;
import javax.swing.table.DefaultTableModel;

/**
 *
 * @author brianjob
 */
public class HitterTable extends AbstractTableModel {
    private DraftMate draft;
    
    public HitterTable(DraftMate dm) {
        this.draft = dm;
    }
    
    public int getColumnCount() {
        return draftMate.player.Hitter.NUM_FIELDS;
    }
    
    public int getRowCount() {
        if (draft == null) {
            System.out.println("NULLLLLLLLLLLLLLLL");
        }
        return draft.numHitters();
    }
    
    public String getColumnName(int col) {
        switch(col) {
            case(Hitter.NAME):
                return "Name";
            case(Hitter.AVG):
                return "Avg";
            case(Hitter.R):
                return "Runs";
            case(Hitter.RBI):
                return "RBIs";
            case(Hitter.HR):
                return "HRs";
            case(Hitter.SB):
                return "Steals";
            case(Hitter.POS):
                return "Position";
            default:
                return "ERROR";
        }
    }
    
    public Object getValueAt(int row, int col) {
        return draft.getHitterStat(row, col);
    }
    
    public Class getColumnClass(int c) {
        switch(c) {
            case(Hitter.NAME):
            case(Hitter.POS):
                return String.class;
            default:
                return Double.class;
        }
    }
    
    public void setValueAt(Object value, int row, int col){
        // maybe implement later
    }
    
    public boolean isCellEditable(int rowIndex, int columnIndex) {
        return false;
    }
}
